package demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 何华树
 * Date: 2024-09-17
 * Time: 18:43
 */
public class Student {
    //使用private 修饰成员变量
    private String name;
    private int age;
    private String StuNum;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getStuNum() {
        return StuNum;
    }

    public void setStuNum(String stuNum) {
        StuNum = stuNum;
    }

    public static void main(String[] args) {
        Student student = new Student(); // 实例化一个对象

        //通过类内的公共的方法（get×××和set××× ），对私有的成员变量进行访问。
        student.setName("小明");
        student.setAge(10);
        student.setStuNum("1234");

        //通过get×××方法，过去 成员变量，进行打印，验证是否通过 set××× 方法，成功进行了赋值
        System.out.println(student.getName());
        System.out.println(student.getAge());
        System.out.println(student.getStuNum());

    }
}
